---
apiVersion: batch/v1
kind: Job
metadata:
  name: gtxsdb-remove-job
  namespace: {{ namespace }}
spec:
  selector:
    matchLabels:
      job-name: gtxsdb-remove-job
  template:
    metadata:
      creationTimestamp: null
      labels:
        job-name: gtxsdb-remove-job
    spec:
      imagePullSecrets:
      - name: harbor-qingzhou
      containers:
      - image: harbor.cloud.netease.com/qztest/skiff-tools:v1.4-20200525
        command: ['sh', '-c', 'echo "all db removed completed"']
        name: gtxsdb-remove-job
        imagePullPolicy: IfNotPresent
      restartPolicy: Never
      initContainers:
      - name: gtxs-server{{ mysql_suffix }}
        image: harbor.cloud.netease.com/qztest/skiff-tools:v1.4-20200525
        imagePullPolicy: IfNotPresent
        command:
        - bash
        - -c
        - "mysql -h {{ mysql['gtxs_server']['host'] }} -P {{ mysql['gtxs_server']['port'] }} -u {{ mysql['gtxs_server']['user']}} -p{{mysql['gtxs_server']['passwd']}} -e 'DROP DATABASE IF EXISTS gtxs_server{{ mysql_suffix }};'"
      - name: gtxs-lock{{ mysql_suffix }}
        image: harbor.cloud.netease.com/qztest/skiff-tools:v1.4-20200525
        imagePullPolicy: IfNotPresent
        command:
        - bash
        - -c
        - "mysql -h {{ mysql['gtxs_lock']['host'] }} -P {{ mysql['gtxs_lock']['port'] }} -u {{ mysql['gtxs_lock']['user']}} -p{{mysql['gtxs_lock']['passwd']}} -e 'DROP DATABASE IF EXISTS gtxs_lock{{ mysql_suffix }};'"
      - name: gtxs-demo{{ mysql_suffix }}
        image: harbor.cloud.netease.com/qztest/skiff-tools:v1.4-20200525
        imagePullPolicy: IfNotPresent
        command:
        - bash
        - -c
        - "mysql -h {{ mysql['gtxs_demo']['host'] }} -P {{ mysql['gtxs_demo']['port'] }} -u {{ mysql['gtxs_demo']['user']}} -p{{mysql['gtxs_demo']['passwd']}} -e 'DROP DATABASE IF EXISTS gtxs_demo{{ mysql_suffix }};'"
